home *** CD-ROM | disk | FTP | other *** search
- Path: sun001.spd.dsccc.com!spd!jmccarty
- From: jmccarty@spd.dsccc.com (Mike McCarty)
- Newsgroups: comp.lang.c
- Subject: Re: Watch out! C "gotcha!"
- Date: 15 Feb 1996 19:41:43 GMT
- Organization: DSC Communications Corporation, Plano, Texas USA
- Message-ID: <4g029n$hpd@sun001.spd.dsccc.com>
- References: <4fthhh$7th@blackice.winternet.com> <1996Feb15.021301.2697@cannon.interramp.com>
- NNTP-Posting-Host: aplo139.spd.dsccc.com
-
- In article <1996Feb15.021301.2697@cannon.interramp.com>,
- Ronald C. McFarland <rcm@one.net> wrote:
- )mschwarz@winternet.com (Michael Schwarz) is astonished to find that:
- )
- )> [plain 'ol C labels can be embedded (and used) inside of switch statements]
- )>
- )>Does anyone know of:
- )>
- )> [snip]
- )>
- )>3) The ANSI party line on labels -- is there an ANSI enforcement option
- )> that guarantees a warning on a construct like this? (If not, does
- )> anyone know how to suggest revisions to the X3-J11 standard?)
- )
- )Labels embedded inside the body of "switch" statements are perfectly legal.
- )This has always been true and, if you think about it, is no different than
- )embedding labels inside the bodies of "for" statements, "while" statements,
- )or what-have-you statements.
-
- [cut]
-
- But there are languages which would catch this type of error. C is
- better than Fortran in this respect, because it forces declaration of
- variables. Unfortunately, in C, labels are self-declaring as are
- variables in Fortran. This is a defect in the language, but one which we
- must live with or choose another language. Pascal is superior to C in
- this respect.
-
- I'm not trying to start a "my language is better than yours" thread.
-
- Mike
- ----
- char *p="char *p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
-
- I don't speak for DSC. <- They make me say that.
-